package cn.lbd.kill.server.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executors;

/**
 * @author LBD
 * @version v12.0.1
 * @date 2020-07-11
 * 定时任务多线程处理的通用化配置
 */
@Configuration
public class SchedulerConfig implements SchedulingConfigurer {

    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        //创建一个线程池，可以调度命令在给定的延迟之后运行，或定期执行，用于搭配定时器使用的线程池种类
        scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(10));
    }
}
